#ifndef __UPDATEDATA_H__
#define __UPDATEDATA_H__

#include "BasicInclude.h"

#define PACKAGE_BUFF_SIZE	(4*1024)

typedef struct __UpdatePackageInfo
{
	//update package size
	uint32_t u32PackageSize;
	//update package haved saved
	uint32_t u32PackageSavedSize;
	//update package have received, include saved and 
	//buffered to buffer
	uint32_t u32PackageHaveReceivedSize;
	
	//current buffered counter
	uint32_t u32PackageBuffCnt;
	//uint32_t u32PackageHaveBuffed;
	//package buffer
	uint8_t u32PackageBuff[PACKAGE_BUFF_SIZE];
	
	uint16_t u16ModbusCRC16;
	
	uint16_t u16Reserved;
	
} UpdatePackageInfo;

typedef enum
{
	eCanCmdReserved = 0,
	ePrepareUpdate,				//0x01 up machine send, down machine enter update mode
	ePrepareUpdateRes,		//0x02 down machine send and enter mode ok
	eStartUpdate,					//0x03 up machine send, ask down machine start request update package data
	eStartUpdateRes,			//0x04 down machine send and ask up machine response update package data
	eUpdateDataPackage,		//0x05 up machine send, this is update package data
	eStartUpdateCrc,			//0x06 up machine send, previous package is last package, this pakcage is crc
	eStartUpdateCrcRes,		//0x07 down machine send, calculate package crc and compare with up machine give crc		
	eCheckUpdate,					//0x08 up machine send, tell downmachine update ok, reset machine
	eCheckUpdateRes				//0x09 down machine send, tell upmachine update ok, reset machine
	
} eUpdateCmdSet;

UpdatePackageInfo *GetUpdatePackageInfo(void);
void InitUpdatePackageInfo(void);

uint8_t SvrCmdResponseProc(uint8_t cmd, void *data, uint32_t data_length, void *response_data, uint32_t *response_length);
#endif

